<script language="javascript">
function init(){
    document.getElementById("span1").innerHTML="测试修改SPAN里的值";
	/*
    document.getElementById("text1").value="name";
	document.getElementById("text2").value="value";
	//*/
    document.getElementById("button1").value="读取";
    document.getElementById("button2").value="写入";
}
function readcookie(){
	var arr=document.cookie.split('; ');
	for(var key in arr){
		var row=arr[key].split('=');
		if(row[0]==document.getElementById("text1").value){
			alert(row[1]);
		}
	}
}
function writecookie(){
	var name=document.getElementById("text1").value;
	var value=document.getElementById("text2").value;
	if(name==""){
		alert('名字不能为空！');
		return;
	}
	var d=new Date();
	d.setTime(d.getTime()+5000);
	document.cookie=name+"="+value+"; expires="+d.toGMTString();
	alert('写入成功');
}
</script>
<body onload="init();">
<span id="span1">loading...</span><br />
<input id="text1" type="text" value="">=<input id="text2" type="text" value=""><br />
<input id="button1" type="button" value="按钮1" onclick="readcookie()">
<input id="button2" type="button" value="按钮1" onclick="writecookie()"><br />
<!--
<body onload="init();">
window.resizeTo(400,300);
============
<script language="javascript">
document.getElementById("cook").innerHTML="测试修改SPAN里的值";
document.getElementById("t1").value="hello你好";
document.getElementById("b1").value="谢谢";
</script>
=============
<script language="javascript">
document.getElementById("span1").innerHTML="测试修改SPAN里的值";
document.getElementById("text1").value="hello你好";
document.getElementById("button1").value="谢谢";
</script>
<span id="span1">loading...</span><br />
<input id="text1" type="text" value=""><br />
<input id="button1" type="button" value="按钮"><br />
==============
<span id="span1">loading...</span><br />
<input id="text1" type="text" value=""><br />
<input id="button1" type="button" value="按钮"><br />
<script language="javascript">
document.getElementById("span1").innerHTML="测试修改SPAN里的值";
document.getElementById("text1").value="hello你好";
document.getElementById("button1").value="谢谢";
</script>
==============
<script language="javascript">
function init(){
    document.getElementById("span1").innerHTML="测试修改SPAN里的值";
    document.getElementById("text1").value="hello你好";
    document.getElementById("button1").value="谢谢";
}
</script>
*/
<body onload="init();">
<span id="span1">loading...</span><br />
<input id="text1" type="text" value=""><br />
<input id="button1" type="button" value="按钮"><br /
-->
